<template>
	<slot :controller="controller" :store="store" :model="model">
		<AppLayoutLeft v-if="store.mainMenuPosition == 'LEFT'" :class="classNames">
			<template #appHeaderLeft>
				<div class="app-header__left__logo">
					<slot
						name="ViewLogo"
						:controller="controller"
						:store="store"
						:model="model"
					>
						<AppIconText
							v-if="store.showLogo"
							:imgPath="model.appIconPath"
						></AppIconText>
					</slot>
					<slot
						name="ViewCaption"
						:controller="controller"
						:store="store"
						:model="model"
					>
						<AppCaptionBar
							:caption="model.caption"
							:title="model.title"
							:capPSLanguageRes="model.capPSLanguageRes"
							:titlePSLanguageRes="model.titlePSLanguageRes"
							:openType="openType"
						></AppCaptionBar>
					</slot>
				</div>
			</template>
			<template #appHeaderCenter>
				<slot
					name="ViewBreadCrumb"
					:controller="controller"
					:store="store"
					:model="model"
				>
					<AppBreadCrumb v-if="store.showBreadCrumb"></AppBreadCrumb>
				</slot>
			</template>
			<template #appHeaderRight>
				<slot
					name="ViewOrgSelect"
					:controller="controller"
					:store="store"
					:model="model"
					><AppOrgSector v-if="store.showOrgSelect"></AppOrgSector
				></slot>
				<slot
					name="ViewLang"
					:controller="controller"
					:store="store"
					:model="model"
					><AppLang v-if="store.showLang"></AppLang
				></slot>
				<slot
					name="ViewTheme"
					:controller="controller"
					:store="store"
					:model="model"
					><AppTheme v-if="store.showThemeSetting"></AppTheme
				></slot>
				<slot
					name="ViewUser"
					:controller="controller"
					:store="store"
					:model="model"
					><AppUser v-if="store.showUserInfo"></AppUser
				></slot>
				<slot
					name="ViewLock"
					:controller="controller"
					:store="store"
					:model="model"
					><AppLockScreen v-if="store.showLockScreen"></AppLockScreen
				></slot>
				<slot
					name="ViewFull"
					:controller="controller"
					:store="store"
					:model="model"
					><AppFullScreen v-if="store.showFullScreen"></AppFullScreen
				></slot>
				<slot
					name="ViewMessage"
					:controller="controller"
					:store="store"
					:model="model"
					><AppMessagePopover v-if="store.showNotice"></AppMessagePopover
				></slot>
			</template>
			<template #default>
				<slot
					name="AppUsr0210019609Menu"
					:controller="controller"
					:store="store"
					:model="model"
					:actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }"
				>
					<Usr0210019609MenuMenu
						:mode="store.mainMenuPosition"
						viewStyle="DEFAULT"
						:isDefaultPage="model.defaultPage"
						:isBlankMode="model.blankMode"
						:defPSAppView="model.defPSAppView"
						:counterData="store.counterData"
						name="appmenu"
						v-bind="model.ctrlParams.appmenu"
						:context="store.context"
						:viewParams="store.viewParams"
						:closeView="store.closeView"
						:pLoadingHelper="store.loadingHelper"
						:pViewCtx="store.viewCtx"
						@ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
						@ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
						@ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"
					></Usr0210019609MenuMenu>
				</slot>
			</template>
			<template #tabPageExp v-if="store.showTabPageExp">
				<slot
					name="ViewTabPage"
					:controller="controller"
					:store="store"
					:model="model"
					><TabPageExp></TabPageExp
				></slot>
			</template>
			<template #navPos>
				<slot
					name="ViewNavPos"
					:controller="controller"
					:store="store"
					:model="model"
					><AppNavPos></AppNavPos
				></slot>
			</template>
			<template #appFooter>
				<slot
					name="ViewFooter"
					:controller="controller"
					:store="store"
					:model="model"
					><AppCopyRight></AppCopyRight
				></slot>
			</template>
		</AppLayoutLeft>
		<AppLayoutTop v-else :class="classNames">
			<template #appHeaderLeft>
				<div class="app-header__left__logo">
					<slot
						name="ViewLogo"
						:controller="controller"
						:store="store"
						:model="model"
					>
						<AppIconText
							v-if="store.showLogo"
							:imgPath="model.appIconPath"
						></AppIconText>
					</slot>
					<slot
						name="ViewCaption"
						:controller="controller"
						:store="store"
						:model="model"
					>
						<AppCaptionBar
							:caption="model.caption"
							:title="model.title"
							:capPSLanguageRes="model.capPSLanguageRes"
							:titlePSLanguageRes="model.titlePSLanguageRes"
							:openType="openType"
						></AppCaptionBar>
					</slot>
				</div>
			</template>
			<template #appHeaderRight>
				<slot
					name="ViewOrgSelect"
					:controller="controller"
					:store="store"
					:model="model"
					><AppOrgSector v-if="store.showOrgSelect"></AppOrgSector
				></slot>
				<slot
					name="ViewLang"
					:controller="controller"
					:store="store"
					:model="model"
					><AppLang v-if="store.showLang"></AppLang
				></slot>
				<slot
					name="ViewTheme"
					:controller="controller"
					:store="store"
					:model="model"
					><AppTheme v-if="store.showThemeSetting"></AppTheme
				></slot>
				<slot
					name="ViewUser"
					:controller="controller"
					:store="store"
					:model="model"
					><AppUser v-if="store.showUserInfo"></AppUser
				></slot>
				<slot
					name="ViewLock"
					:controller="controller"
					:store="store"
					:model="model"
					><AppLockScreen v-if="store.showLockScreen"></AppLockScreen
				></slot>
				<slot
					name="ViewFull"
					:controller="controller"
					:store="store"
					:model="model"
					><AppFullScreen v-if="store.showFullScreen"></AppFullScreen
				></slot>
				<slot
					name="ViewMessage"
					:controller="controller"
					:store="store"
					:model="model"
					><AppMessagePopover v-if="store.showNotice"></AppMessagePopover
				></slot>
			</template>
			<template #default>
				<slot
					name="AppUsr0210019609Menu"
					:controller="controller"
					:store="store"
					:model="model"
					:actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }"
				>
					<Usr0210019609MenuMenu
						:mode="store.mainMenuPosition"
						viewStyle="DEFAULT"
						:isDefaultPage="model.defaultPage"
						:isBlankMode="model.blankMode"
						:defPSAppView="model.defPSAppView"
						:counterData="store.counterData"
						name="appmenu"
						v-bind="model.ctrlParams.appmenu"
						:context="store.context"
						:viewParams="store.viewParams"
						:closeView="store.closeView"
						:pLoadingHelper="store.loadingHelper"
						:pViewCtx="store.viewCtx"
						@ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
						@ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
						@ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"
					></Usr0210019609MenuMenu>
				</slot>
			</template>
			<template #tabPageExp v-if="store.showTabPageExp">
				<slot
					name="ViewTabPage"
					:controller="controller"
					:store="store"
					:model="model"
					><TabPageExp></TabPageExp
				></slot>
			</template>
			<template #navPos>
				<slot
					name="ViewNavPos"
					:controller="controller"
					:store="store"
					:model="model"
					><AppNavPos></AppNavPos
				></slot>
			</template>
			<template #appFooter>
				<slot
					name="ViewFooter"
					:controller="controller"
					:store="store"
					:model="model"
					><AppCopyRight></AppCopyRight
				></slot>
			</template>
		</AppLayoutTop>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/views/{{appModules}}/{{pages@APPINDEXVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppLayoutTop, AppLayoutLeft } from '@components/layout/app-layout';
import Usr0210019609MenuMenu from '@widgets/app/usr-0210019609-menu-menu/usr-0210019609-menu-menu.vue';
import {
	IEvent,
	IIndexViewAbility,
	IIndexViewStore,
	IndexViewActionType,
	IParam,
} from '@/core';
import {
	useController,
	useProps,
	useBasic,
	useAction,
} from './uaa-admin-view-hook';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	model,
	getClassNames,
	useNavParamsBind,
	useEventBind,
	handleQuickSearch,
	handleToolbarItemClick,
	handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'view-action',
		name: string,
		action: IndexViewActionType,
		data: IParam[]
	): void;
	(event: 'view-init', name: string, data: IIndexViewAbility): void;
	(event: 'view-mounted', name: string, data: IParam): void;
	(event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: IIndexViewStore = controller.getStore();

onMounted(() => {
	controller.viewMounted();
});

onUnmounted(() => {
	controller.viewDestroy();
});
</script>
